package com.twu.biblioteca;

import com.twu.biblioteca.controller.BookController;
import com.twu.biblioteca.controller.MembershipController;
import com.twu.biblioteca.controller.MovieController;
import com.twu.biblioteca.menuitem.*;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * User: Thoughtworker
 * Date: 8/24/13
 * Time: 10:10 PM
 * To change this template use File | Settings | File Templates.
 */
public class Initializer {

    public HashMap<String, Book> intiliazeBooks(int numberOfBooks) {
        HashMap<String, Book> books = new HashMap<String, Book>();
        Book book;
        for (int i = 0; i < numberOfBooks; i++) {
            book = new Book("Book " + (i + 1));
            books.put(book.getName(), book);
        }
        return books;
    }

    public HashMap<String, Movie> intiliazeMovies(int numberOfMovies) {
        HashMap<String, Movie> movies = new HashMap<String, Movie>();
        Movie movie;
        for (int i = 0; i < numberOfMovies; i++) {
            movie = new Movie("Movie " + (i + 1), (1990 + i), "Director " + (i + 1), 5);
            movies.put(movie.getName(), movie);
        }
        return movies;
    }


    public HashMap<Integer, MenuItem> initializeMenuItems(BookController bookController, MovieController movieController, MembershipController membershipController) {
        HashMap<Integer, MenuItem> menuItemHashMap = new HashMap<Integer, MenuItem>();
        menuItemHashMap.put(1, new MenuItemShowBooks("See List of Books",bookController));
        menuItemHashMap.put(2, new MenuItemReserveBook("Reserve Book",bookController));
        menuItemHashMap.put(3, new MenuItemCheckMembership("Check Membership",membershipController ));
        menuItemHashMap.put(4, new MenuItemShowMovies("See List of Movies",movieController));


        return menuItemHashMap;
    }

    public HashMap<String, User> initializeUsers(int numberOfUsers) {
        HashMap<String, User> users = new HashMap<String, User>();
        User user;
        for (int i = 0; i < numberOfUsers; i++) {
            user = new User("username" + (i + 1), "password" + (i + 1), "name" + (i + 1), "email" + (i + 1),"phone number" + (i + 1));
            users.put(user.getUsername(), user);
        }
        return users;
    }
}
